import request from "@/utils/request";
import type {
  AddOrUpdateSkuParams,
  GetSkuListResponse,
} from "./model/skuModel";
enum api {
  addSku = "/admin/product/saveSkuInfo",
  getSkuList = "/admin/product/list",
  skuCancelSale = "/admin/product/cancelSale",
  skuOnSale = "/admin/product/onSale",
  getSkuById = "/admin/product/getSkuById",
  deleteSku = "/admin/product/deleteSku",
}

/**
 * 删除sku的接口
 * @param skuId
 * @returns null
 */
export const deleteSkuApi = (skuId: number) => {
  return request.delete<any, null>(api.deleteSku + `/${skuId}`);
};
/**
 * 通过id获取商品sku详情的接口
 * @param skuId
 * @returns AddOrUpdateSkuParams
 */
export const getSkuByIdApi = (skuId: number) => {
  return request.get<any, AddOrUpdateSkuParams>(api.getSkuById + `/${skuId}`);
};
/**
 * 取消上架的sku接口
 * @param skuId
 * @returns null
 */
export const skuCancelSaleApi = (skuId: number) => {
  return request.get<any, null>(api.skuCancelSale + `/${skuId}`);
};
/**
 * 上架sku的接口
 * @param skuId
 * @returns null
 */
export const skuOnSaleApi = (skuId: number) => {
  return request.get<any, null>(api.skuOnSale + `/${skuId}`);
};
/**
 * 获得sku列表的接口
 * @param page 页码
 * @param limit 每页条数
 * @returns
 */
export const getSkuListApi = (page: number, limit: number) => {
  return request.get<any, GetSkuListResponse>(
    api.getSkuList + `/${page}/${limit}`
  );
};
/**
 * 添加sku的接口
 * @param data AddOrUpdateSkuParams
 * @returns null
 */
export const addSkuApi = (data: AddOrUpdateSkuParams) => {
  return request.post<any, null>(api.addSku, data);
};
